package sistema.validador;
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 29/3/2006 21:06:19
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   ValidatorSpace.java

import java.io.*;
import java.util.StringTokenizer;

class ValidatorSpace
{

    public void Createfiles(String input1, String output1, String answer1, String result1)
    {
        if(logstat)
            try
            {
                log = new PrintWriter(new FileOutputStream(output1), true);
                VersionInfo vi = new VersionInfo();
                log.println("# Validator version: " + vi.getVersionNumber() + " " + vi.getVersionDate());
                log.println("-------------------------***STARTING TO CREATE FILES TO READ AND WRITE***-----------------------");
                log.println("-------------------------***CREATED LOG FILE !!***-----------------------");
                logstat = false;
            }
            catch(IOException e)
            {
                System.out.println("FAILED TO CREATE THE LOG FILE TO WRITE " + e.toString());
                log.println("FAILED TO CREATE THE LOG FILE TO WRITE " + e.toString());
            }
        try
        {
            tempans = new PrintWriter(new FileOutputStream("temp2.txt"), true);
            log.println("-------------------------***CREATING SECOND TEMP FILE TO WRITE***-----------------------");
        }
        catch(IOException e)
        {
            System.out.println("FAILED TO CREATE THE TEMP FILE TO WRITE " + e.toString());
            log.println("FAILED TO CREATE THE TEMP2 FILE TO WRITE " + e.toString());
        }
        try
        {
            input = new FileReader(input1);
            log.println("-------------------------***SUCESSFULLY OPENED INPUT FILE (" + input1 + ") TO READ***-----------------------");
        }
        catch(IOException e)
        {
            System.out.println("FAILED TO OPEN INPUT FILE (" + input1 + ") TO READ..." + e.toString());
            log.println("FAILED TO OPEN INPUT FILE (" + input1 + ") TO READ..." + e.toString());
        }
        try
        {
            answer = new FileReader(answer1);
            log.println("-------------------------***SUCESSFULLY OPENED ANSWER FILE (" + answer1 + ") TO READ***-----------------------");
        }
        catch(IOException e)
        {
            System.out.println("FAILED TO OPEN INPUT (" + answer1 + ") FILE TO READ..." + e.toString());
            log.println("FAILED TO OPEN INPUT FILE (" + answer1 + ") TO READ..." + e.toString());
        }
        try
        {
            result = new PrintWriter(new FileOutputStream(result1), true);
            log.println("-------------------------***SUCESSFULLY OPENED RESULT FILE (" + result1 + ") TO WRITE***-----------------------");
        }
        catch(IOException e)
        {
            System.out.println("FAILED TO CREATE THE RESULT FILE (" + result1 + ") TO WRITE. " + e.toString());
            log.println("FAILED TO CREATE THE RESULT FILE (" + result1 + ") TO WRITE. " + e.toString());
        }
        log.println("-------------------------***FINISHED CREATING FILES***-----------------------");
    }

    public void diffSp(FileReader fr, String temp1, PrintWriter log)
        throws IOException
    {
        try
        {
            PrintWriter pw = new PrintWriter(new FileOutputStream(temp1), true);
            log.println("-------------------------***WRITING IN TEMP FILE (" + temp1 + ")***-----------------------");
            log.println("-------------------------*** INVOKING VALIDATOR SPACE ***---------------------------");
            String line = new String();
            BufferedReader br = new BufferedReader(fr);
            for(line = br.readLine(); line != null; line = br.readLine())
            {
                StringTokenizer st = new StringTokenizer(line, " \t");
                StringBuffer sb;
                for(sb = new StringBuffer(); st.hasMoreTokens(); sb = sb.append(st.nextToken() + " "));
                pw.println(sb.toString().trim());
                log.println(sb.toString().trim());
            }

        }
        catch(IOException e)
        {
            System.out.println("FAILED TO WRITE IN THE TEMP FILE (" + temp1 + ") " + e.toString());
            log.println("FAILED TO WRITE IN  THE TEMP FILE (" + temp1 + ") " + e.toString());
        }
        log.println("-------------------------***END EXECUTING VALIDATOR SPACE***-----------------------");
    }

    public ValidatorSpace()
    {
        logstat = true;
        foundcr = false;
    }

    public boolean isGlobalValidator()
    {
        return globalValidator;
    }

    public void setGlobalValidator(boolean newGlobalValidator)
    {
        globalValidator = newGlobalValidator;
    }

    private PushbackReader pr;
    public boolean logstat;
    public boolean foundcr;
    public FileReader answer;
    public FileReader input;
    public PrintWriter log;
    public PrintWriter tempans;
    public PrintWriter result;
    public boolean globalValidator;
}